package com.ebarlas.fractal.compile;

import java.util.regex.Pattern;

public class Terminal {
    private TerminalType type;
    private Pattern pattern;
    private StackCommand[] commands;
    
    public Terminal(TerminalType type, Pattern pattern, StackCommand ... commands) {
        this.type = type;
        this.pattern = pattern;
        this.commands = commands;
    }
    
    public Terminal(TerminalType type, String regex, StackCommand ... commands) {
        this(type, Pattern.compile(regex), commands);
    }   
    
    public Terminal(TerminalType type, Pattern pattern) {
        this(type, pattern, (StackCommand)null);
    }   
    
    public Terminal(TerminalType type, String regex) {
        this(type, regex, (StackCommand)null);
    }    
    
    public Pattern getPattern() {
        return pattern;
    }
    
    public TerminalType getType() {
        return type;
    }
    
    public StackCommand getCommand() {
        return commands[0];
    }
    
    public StackCommand getCommand(int index) {
        return commands[index];
    }    
}
